<template>
  <div>
    <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
      <h3>供应商审核</h3>
    </div>

    <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
      <el-row>
        <el-col :span="12">
          <el-form-item label="供应商编号">
            <el-input v-model="usernumber"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="用户名">
            <el-input v-model="username"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="真实姓名">
            <el-input v-model="realname"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机号">
            <el-input v-model="phone"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="公司名">
            <el-input v-model="supname"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="初始化等级">
            <el-input v-model="level"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="商品类型">
            <el-input v-model="type"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="审核日期">
            <el-input type="date" placeholder="选择日期" v-model="audittime" style="width: 100%;"></el-input>
          </el-form-item>
        </el-col>
      </el-row>


      <el-row>
        <el-col :span="24">
          <el-form-item label="资质图片">
            <div class="demo-image__placeholder">
              <div class="block">
                <el-image :src="imgurl"></el-image>
              </div>
            </div>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item label="问题反馈">
        <el-input type="textarea" v-model="auditfeedback"></el-input>
      </el-form-item>

      <el-row>
        <el-col :span="12" style="text-align: center">
          <el-button type="primary" @click="passAudit" >通过审核</el-button>
        </el-col>
        <el-col :span="12" style="text-align: center">
          <el-button type="primary" @click="noPassAudit">不通过</el-button>
        </el-col>
      </el-row>

    </el-form>
  </div>
</template>

<script>
export default {
  name: "ProviderAuditDialog",
  props:{
    usercodeTag:String
  },
  data(){
    return{
      userid:'',
      username:'',
      realname:'',
      usernumber:'',
      phone:'',
      imgurl:'',
      supname:'',
      type:'',
      level:'',
      state:'',
      audittime:'',
      auditfeedback:''
    }
  },
  mounted() {
    this.init(this.usercodeTag)
  },
  methods:{
    init(tag){
      let url = '/csc/sys-user/selectProviderById/'+tag
      console.log(url)
      this.$axios.get(url).then(r=>{
        console.log(r.data)
        this.userid = r.data.userid
        this.username = r.data.username
        this.realname = r.data.realname
        this.usernumber = r.data.usernumber
        this.phone = r.data.phone
        this.level = r.data.level
        this.supname = r.data.supname
        this.imgurl = r.data.imgurl
        this.type = r.data.type
        this.state = r.data.state
      })
    },
    passAudit(){
      this.$confirm('确定通过审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = '/csc/sys-user/passAudit'
        let fd = new FormData
        fd.append("usernumber",this.usernumber)
        fd.append("state",1)
        fd.append("userid",this.userid)
        fd.append("audittime",this.audittime)
        fd.append("auditfeedback",this.auditfeedback)
        fd.append("level",this.level)
        this.$axios.post(url,fd).then(r=>{
          this.$message.success(r.data)
          this.$emit("closeDialog")
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    noPassAudit(){
      this.$confirm('确定不通过审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = '/csc/sys-user/noPassAudit'
        let fd = new FormData
        fd.append("usernumber",this.usernumber)
        fd.append("state",2)
        fd.append("userid",this.userid)
        fd.append("audittime",this.audittime)
        fd.append("auditfeedback",this.auditfeedback)
        fd.append("level",this.level)
        this.$axios.post(url,fd).then(r=>{
          this.$message.success(r.data)
          this.$emit("closeDialog")
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    }
  }
}
</script>

<style scoped>

</style>